<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateForbiddenUserTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_forbidden', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->default(0)->comment('用户ID');
            $table->unsignedInteger('forbid_mins')->default(1)->comment('封禁时间（分钟）');
            $table->unsignedInteger('start_ts')->default(0)->comment('开始封禁时间');
            $table->unsignedInteger('end_ts')->default(0)->comment('结束封禁时间');
            $table->timestamps();
            $table->unsignedTinyInteger('flag')->default(1)->comment('封禁状态：1-封禁，0-无效');
            $table->index('user_id', 'user_id');
            $table->index('end_ts', 'end_ts');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_forbidden');
    }
}
